package ru.ipccenter.belovseregas.robot;


import java.util.Random;

import ru.ipccenter.belovseregas.point.Point;
import ru.ipccenter.belovseregas.world.World;

public class Robot {
	private World world;
	private Point point;

	public Robot() {
		world = null;
		point = null;
	}
	
	public Robot(World world, int x, int y) {
		this.world = world;
		point = this.world.getPoint(x, y);
	}
	
	public World getWorld() {
		return world;
	}

	public void setWorld(World world) {
		this.world = world;
	}

	public Point getPoint() {
		return point;
	}

	public void setPoint(Point point) {
		this.point = point;
	}

	public void move() {
		Random rand = new Random();
		int x = point.getX();
		int y = point.getY();
		int addX = rand.nextInt(2);
		int addY = rand.nextInt(2);
		x += addX;    // some coordinate changes
		y += addY;  
		point.delRobot(this);
		if (x>=0 && x < world.getM() && y >= 0 && y < world.getN()) {
			point = world.getPoint(x, y);
			point.addRobot(this);
		} else {
			point = null;
		}
	}

}
